local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script, ClientOHOH.files.OHOHOLYBUIBase());
local CallBackManager = ClientOHOH.load.CallBackManager();
local BtnHelper = ClientOHOH.load.BtnHelper();
local LanguageHelper=_G.LanguageHelper 
local BigNumberHelper = ClientOHOH.load.BigNumberHelper();
local ConnectClass=_G.CommonOHOH.load.Connect();

function InitInsts(ui)
	ui.insts = {};

    ui.insts.cell = "ctrl.cell"
    ui.insts.close = "ctrl.close"
    ui.insts.list = "ctrl.root"
    ui.insts.titleNum = "ctrl.titleNum"
end

function M.new(...)
	return M(...);
end;

function M.ctor(self)
	InitInsts(self)
	M.super.ctor(self, ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.AFKGui"));
    self.insts.cell.Visible = false
    self:AddConnect()
end;

function M.AddConnect(self)
    CallBackManager:AddRbxConnect(self,self.insts.close.Activated,function()
        self:Hide()
    end)
end


local cellStr = {
    had = "ctrl.get",
    name = "ctrl.name",
    notHad = "ctrl.notGet",
    num = "ctrl.num"
}

function M.CreateCell(self,afkObj)
    local cellObj = self.insts.cell:Clone()
    cellObj.Parent = self.insts.list
    cellObj.Visible = true
    local cell = self:InitUiInst2(cellObj,cellStr)
    self:InitUiObj(cellObj)
    cell.had.Visible = afkObj:IsComplete()
    cell.notHad.Visible = not afkObj:IsComplete()
    cell.name.Text = afkObj:GetDes()
    cell.num.Text = afkObj:GetValueStr()
    afkObj.UpdateEvent:Connect(function()
        self:SetIsGet(cell,afkObj:IsComplete())
    end)
end

--填充信息
function M.FullData(self,AFKObjList)
    for index, value in pairs(AFKObjList) do
        self:CreateCell(value)
    end
end

--设置是否完成
function M.SetIsGet(self,cell,isGet)
    cell.notHad.Visible =not isGet
    cell.had.Visible = isGet
end



function M.dtor(self)
	M.super.dtor(self);
end;



return M
